package cn.itcast.nems.journal.service.impl;

import cn.itcast.nems.journal.service.JournalTransferOrderRelationshipService;
import cn.itcast.nems.studentrecord.dao.entity.JournalTransferOrderRelationship;
import cn.itcast.nems.studentrecord.dao.mapper.JournalTransferOrderRelationshipMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class JournalTransferOrderRelationshipServiceImpl implements JournalTransferOrderRelationshipService {
    private final JournalTransferOrderRelationshipMapper journalTransferOrderRelationshipMapper;

    @Override
    public List<JournalTransferOrderRelationship> findListByRecordId(String recordId) {
        return journalTransferOrderRelationshipMapper.selectList(
                new LambdaQueryWrapper<JournalTransferOrderRelationship>()
                        .eq(JournalTransferOrderRelationship::getStudentRecordId, recordId)
                        .eq(JournalTransferOrderRelationship::getDeletedFlag, false)
                        .orderByDesc(JournalTransferOrderRelationship::getCreatedDatetime));
    }

    @Override
    public JournalTransferOrderRelationship getByOrderId(String orderId) {
        return journalTransferOrderRelationshipMapper.selectOne(new LambdaQueryWrapper<JournalTransferOrderRelationship>()
                .eq(JournalTransferOrderRelationship::getOrderId, orderId)
                .eq(JournalTransferOrderRelationship::getDeletedFlag, false));
    }
}
